home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Sample.bin / UISwitchListener.java < prev    next >
Text File  |  1998-06-30  |  2KB  |  51 lines

  1. /*
  2.  * @(#)UISwitchListener.java    1.1 98/02/04
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. import java.awt.*;
  22. import java.beans.*;
  23. import java.awt.event.*;
  24. import com.sun.java.swing.*;
  25. import com.sun.java.swing.event.*;
  26.  
  27.  
  28. /**
  29.   * This class listens for UISwitches, and updates a given component.
  30.   *
  31.   * @version 1.1 02/04/98
  32.   * @author Steve Wilson
  33.   */
  34. public class UISwitchListener implements PropertyChangeListener {
  35.     JComponent componentToSwitch;
  36.  
  37.     public UISwitchListener(JComponent c) {
  38.         componentToSwitch = c;
  39.     }
  40.  
  41.     public void propertyChange(PropertyChangeEvent e) {
  42.         String name = e.getPropertyName();
  43.     if (name.equals("lookAndFeel")) {
  44.         SwingUtilities.updateComponentTreeUI(componentToSwitch);
  45.         componentToSwitch.invalidate();
  46.         componentToSwitch.validate();
  47.         componentToSwitch.repaint();
  48.     }
  49.     }
  50. }
  51.